package com.example.shw

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.widget.SimpleAdapter
import android.widget.StackView

class StackViewActivity : AppCompatActivity(){
    private var stackview : StackView ?= null
    private var imageIds = intArrayOf(R.drawable.i001, R.drawable.i002, R.drawable.i003,
        R.drawable.i004, R.drawable.i005, R.drawable.i006, R.drawable.i007, R.drawable.i008)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activithy_stackview)
        stackview = findViewById(R.id.mstackview)
        val listItems = ArrayList<Map<String, Any>>()
        for (i in imageIds.indices){
            val listItem = HashMap<String,Any>()
            listItem["image"] = imageIds[i]
            listItems.add(listItem)
        }
        val simpleAdapter = SimpleAdapter(this, listItems,
            R.layout.cell, arrayOf("image"), intArrayOf(R.id.image3))
        stackview?.adapter = simpleAdapter
    }
    fun prev(view: View){
        stackview?.showPrevious()
    }
    fun next(view: View){
        stackview?.showNext()
    }
}